package com.atguigu.encryption.service;

import com.atguigu.encryption.param.AsymmetricDecryptParam;
import com.atguigu.encryption.param.AsymmetricEncryptParam;
import com.atguigu.encryption.param.PageParam;
import com.atguigu.encryption.pojo.Encryption;
import com.atguigu.encryption.utils.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

@Service
public interface SymmetricService {
    /**
     * Des
     * @param plaintext
     * @param password
     * @return
     */
    R desEncrypt(String plaintext, String password);

    R desDecrypt(String ciphertext, String password);

    /**
     * Aes
     * @param plaintext
     * @param password
     * @return
     */
    R aesEncrypt(String plaintext, String password);

    R aesDecrypt(String plaintext, String password);

    R getAllEncryption(PageParam pageParam);

    R getAllDecryption(PageParam pageParam);

    // 单向散列，哈希算法
    /**
     * md5
     * @param plaintext
     * @return
     */
    R md5(String plaintext);

    /**
     * sha1
     * @param plaintext
     * @return
     */
    R sha1(String plaintext);

    /**
     * sha256
     * @param plaintext
     * @return
     */
    R sha256(String plaintext);

    /**
     * sm3
     * @param plaintext
     * @return
     */
    R sm3(String plaintext);

    // 非对称加解密
    R getKeys(Integer keySize);

    R getAllKeys(PageParam pageParam);

    /**
     * RSA
     * @param asymmetricEncryptParam
     * @return
     */
    R rsaEncrypt(AsymmetricEncryptParam asymmetricEncryptParam);

    R rsaDecrypt(AsymmetricDecryptParam asymmetricDecryptParam);

    R rsaGetAllEncryption(PageParam pageParam);

    R rsaGetAllDecryption(PageParam pageParam);


    /**
     * SM4加密
     * @param plaintext
     * @param password
     * @return
     */
    R sm4Encrypt(String plaintext, String password);

    /**
     * SM4解密
     * @param ciphertext
     * @param password
     * @return
     */
    R sm4Decrypt(String ciphertext, String password);

    /**
     * SM2加密
     * @param asymmetricEncryptParam
     * @return
     */
    R sm2Encrypt(AsymmetricEncryptParam asymmetricEncryptParam) throws Exception;

    /**
     * SM2解密
     * @param asymmetricDecryptParam
     * @return
     */
    R sm2Decrypt(AsymmetricDecryptParam asymmetricDecryptParam) throws Exception;


    /**
     * 查询密文
     * @param plaintext
     * @param password
     * @param method
     * @return
     */
    R queryCiphertext(String plaintext, String password, String method);

    R queryCiphertext1(String plaintext, String method);

    /**
     * 利用给 redis 进行缓存查询
     * @param plaintext
     * @param password
     * @param method
     * @return
     */
    R queryCiphertextByRedis(String plaintext, String password, String method);
}
